package com.yxkj.syh.app.huarong.activities.splash;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.syh.app.basic.App;
import com.syh.app.basic.base.view_model.BaseViewModel;
import com.syh.app.basic.utils.AppUtil;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.utils.net.ApiObserver;
import com.trello.rxlifecycle2.android.ActivityEvent;
import com.yxkj.syh.app.huarong.bean.VersionCheckResponse;
import com.yxkj.syh.app.huarong.data_center.model.CommonModel;

/**
 * 创建者：SYH
 * 时间：2020/5/25 15:22
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class SplashVM extends BaseViewModel<ActivityEvent> {

    public SplashVM(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<VersionCheckResponse.VersionCheck> mldVersionCheck = new MutableLiveData<>();

    public void versionCheck(){
        String packageName = AppUtil.getPackageName(App.getApplication());
        int platform = 0;
        CommonModel.getCommonModel().versionCheck(packageName, platform, mLifecycleProvider.bindToLifecycle(), new ApiObserver<VersionCheckResponse>() {
            @Override
            public void onSuccess(VersionCheckResponse versionCheckResponse) {
                mldVersionCheck.setValue(versionCheckResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
            }
        });
    }
}

